1. Field of the Invention
The invention relates to memories, and more particularly to data access methods of flash memories.
2. Description of the Related Art
A flash memory comprises a plurality of blocks, and each block comprises a plurality of pages for data storage. When the flash memory receives a write command from a controller, the flash memory writes data to pages of the blocks thereof according to the received write command. When the flash memory receives a read command from the controller, the flash memory reads data from pages of the blocks thereof according to the received read command, and then sends read-out data back to the controller.
After data is written to a spare page of a block of the flash memory, the spare page becomes a data page and data cannot be written to the data page again. The data page can only be programmed with data again after data is erased from all pages of a block containing the data page to return the pages of the block to spare pages. Because a block comprises thousands of pages, erasing data from all pages of a block requires a long time period and causes a long delay. Thus, the controller cannot erase data from a block with a high frequency. Otherwise, the performance of the controller and the flash memory is degraded.
When a host sends a write command to a controller to request the controller to write new data to a write address, and an old page corresponding to the write address has stored old data therein, the controller cannot write the new data received from the host to the old page of a flash memory. The controller, however, still must execute the write command. Ordinarily, the controller selects a spare block from a plurality of blocks of the flash memory, and writes the new data to a spare page of the spare block instead of the old page. There is therefore a mapping relationship between the spare block containing the spare page storing the new data and a target block containing the old page storing the old data. The target block containing the old page storing the old data is referred to as a mother block. The spare block containing the spare page storing the new data is referred to as a child block.
Referring to FIG. 1, a schematic diagram of a child block 104 mapped to a mother block 102 in a flash memory is shown. An address range of a plurality of pages of the mother block 102 is from 0˜1000. The mother block 102 stores old data A0, B0, C0, and D0 which respectively corresponds to address ranges 0˜400, 400˜600, 600˜700, and 700˜1000. When the host requests the controller to writes update data B1 to an address range 400˜600 of the flash memory, because the address range 400˜600 of the mother block 102 has stored the old data B0, the controller cannot write the update B1 to the mother block 102 again. The controller then selects a spare block from the flash memory as a child block 104 mapped to the mother block 102. The controller then copies the old data A0, stores the copied old data A0 to an address range 0˜400 of the child block 104, and then writes the update data B1 received from the host to an address range 400˜600 of the child block 104. Similarly, when the host requests the controller to write update data C1 to an address range 600˜700 of the flash memory, because the address range 600˜700 of the mother block 102 has stored the old data C0, the controller directly writes the update data C1 received from the host to an address range 600˜700 of the child block 104.
When the host requests the controller to write new update data to an address range 0˜700 of the flash memory, because the address ranges 0˜700 of both the mother block 102 and the child block 104 have respectively stored the old data A0˜C0 and A0˜C1, the controller cannot write the new update data received from the host to any of the address ranges 0˜700 of the mother block 102 and the child block 104. Thus, a data access method of a flash memory is required to solve the aforementioned problem.